﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI.WebControls;
using System.Collections;
using System.Web.UI.HtmlControls;

namespace Department.admin
{
    public static class AdminVariablesSingleton
    {
        public const int MAX_FILE_SIZE = 1024 * 1024 * 10;
        static bool wasSortedDesc;

        public static bool WasSortedDesc
        {
            get { return wasSortedDesc; }
            set { wasSortedDesc = value; }
        }
        public static void changeCSS(MasterPage master, string element)
        {
            Control foundControl2 = FindControlRecursive(master, "dynStuff");
            ((HtmlControl)foundControl2).Attributes.Add("class", "select");
            Control foundControl3 = FindControlRecursive(master, "news");
            ((HtmlControl)foundControl3).Attributes.Add("class", "select");
            Control foundControl5 = FindControlRecursive(master, "admin");
            ((HtmlControl)foundControl5).Attributes.Add("class", "select");
            Control foundControl4 = FindControlRecursive(master, "struct");
            ((HtmlControl)foundControl4).Attributes.Add("class", "select");
            Control foundControl6 = FindControlRecursive(master, "materials");
            ((HtmlControl)foundControl6).Attributes.Add("class", "select");


            Control foundControl55 = FindControlRecursive(master, element);
            ((HtmlControl)foundControl55).Attributes.Add("class", "current");


            Control foundControl7 = FindControlRecursive(master, "sub_dynStuff");
            ((HtmlControl)foundControl7).Attributes.Add("class", "select_sub");
            Control foundControl8 = FindControlRecursive(master, "sub_news");
            ((HtmlControl)foundControl8).Attributes.Add("class", "select_sub");
            Control foundControl9 = FindControlRecursive(master, "sub_admin");
            ((HtmlControl)foundControl9).Attributes.Add("class", "select_sub");
            Control foundControl10 = FindControlRecursive(master, "sub_struct");
            ((HtmlControl)foundControl10).Attributes.Add("class", "select_sub");
            Control foundControl11 = FindControlRecursive(master, "sub_materials");
            ((HtmlControl)foundControl11).Attributes.Add("class", "select_sub");

            Control foundControl77 = FindControlRecursive(master, "sub_"+element);
            ((HtmlControl)foundControl77).Attributes.Add("class", "select_sub show");

            
        }
        public static void configureCKEditor(ref CKEditor.NET.CKEditorControl editor)
        {

            editor.Width = 600;
            editor.config.toolbar = new object[]
            {

                new object[] { "Cut", "Copy", "Paste", "PasteText", "PasteFromWord"},
                new object[] { "Undo", "Redo", },

                "/",
                new object[] { "Bold", "Italic", "Underline", "Strike", "-", "Subscript", "Superscript" },
                new object[] { "NumberedList", "BulletedList", "-", "Outdent", "Indent", "Blockquote"},
                new object[] { "JustifyLeft", "JustifyCenter", "JustifyRight", "JustifyBlock" },


                new object[] { "Image", "Flash", "Table", "HorizontalRule", "Smiley", "SpecialChar"},
                "/",
                new object[] { "Styles", "Format", "Font", "FontSize" },
                new object[] { "TextColor", "BGColor" },
                new object[] { "Maximize"}
            };

        }

     
        public static Control FindControlRecursive(Control rootControl, string id)
        {
            if (rootControl != null)
            {
                if (rootControl.ID == id)
                {
                    return rootControl;
                }

                for (int i = 0; i < rootControl.Controls.Count; i++)
                {
                    Control child;

                    if ((child = FindControlRecursive(rootControl.Controls[i], id)) != null)
                    {
                        return child;
                    }
                }
            }

            return null;
        }
        
    }
    
}